package aufgabe1;

import java.util.Random;
import java.lang.Math;

class Pi {
	private long seed;
	private int nsteps;
	private int nstepPrint;
	
	public Pi(long seed, int nsteps, int nstepPrint) {
		this.seed       = seed;
		this.nsteps     = nsteps;
		this.nstepPrint = nstepPrint;
	}

	public void simulate () {
		Random randGen = new XSRandom(seed);
		
		int k = 0;		
		double p, q, s, randX, randY, distance;
		
		for(int n = 1; n <= nsteps; n++) {
			randX = randGen.nextDouble();
			randY = randGen.nextDouble();

			distance = Math.sqrt(Math.pow(randX - 0.5, 2.0) + Math.pow(randY - 0.5, 2.0));

			if (distance <= 0.5) {
				k++;
			}

			if (n >= nstepPrint) {
				p = ((double)k/(double)n);
				q = 1-p;
				s = 4.0*Math.sqrt(p*q/(double)n);
				
				System.out.println(n + "\t" + 4 * p + "\t" + (Math.PI-p) + "\t" + s);
			}
		}
	}
	
    public static void main(String[] args) {
		Pi p = new Pi(Long.parseLong(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));

		p.simulate();
    }
}